<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * This is the extension class from Form Validation Library.
 *
 * @author		akjmgalp
 * @Revision	From SVN
 */

// ------------------------------------------------------------------------
class MY_Form_validation extends CI_Form_validation {

	function unique($value, $params)
	{
		$CI =& get_instance();

		$CI->form_validation->set_message('unique', 'Bu %s zaten kullanılıyor');

		list($model, $field) = explode(".", $params, 2);

		$find = "findOneBy".$field;
		
		if (Doctrine::getTable($model)->$find($value)) {
			return false;
		} else {
			return true;
		}

	}
}